﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Liquid.Windows.Commands.ToolStrips {
	[ProvideProperty("Command", typeof(ToolStripItem))]
	public sealed class ToolStripCommandBinder : CommandBinder<ToolStripItem> {
		protected override bool CanExtend(ToolStripItem extendee) {
			return extendee is ToolStripMenuItem
				|| extendee is ToolStripButton;
			// TODO: Is there anything else that ToolStripCommandBinder could extend?
		}

		protected override CommandBinding CreateBinding(ToolStripItem extendee) {
			if (extendee is ToolStripMenuItem) {
				return new ToolStripMenuItemCommandBinding(
					(ToolStripMenuItem)extendee
				);
			} else if (extendee is ToolStripButton) {
				return new ToolStripButtonCommandBinding(
					(ToolStripButton)extendee
				);
			} else {
				throw new NotSupportedException();
			}
		}
	}
}
